<?php
namespace app\index\controller;

use app\BaseController;

class UserToken extends BaseController
{
    /**
     * * 获取登录凭证token
     * @return mixed|string
     */
    public function getUserToken()
    {
        return (isset($_SERVER['HTTP_TOKEN']) && $_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : '';
    }

    /**
     * 获取用户id
     * @return int
     */
    public function getUserId(): int
    {
        $token = $this->getUserToken();
        return (int)getAuthCode($token, 'DECODE');
    }
}
